{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Calculating Transit Timing Variations (TTV) with REBOUND\n",
    "The following code finds the transit times in a two planet system. The transit times of the inner planet are not exactly periodic, due to planet-planet interactions."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First, let's import the REBOUND and numpy packages."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import rebound\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's set up a coplanar two planet system."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "sim = rebound.Simulation()\n",
    "sim.add(m=1)\n",
    "sim.add(m=1e-5, a=1,e=0.1,omega=0.25)\n",
    "sim.add(m=1e-5, a=1.757)\n",
    "sim.move_to_com()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We're now going to integrate the system forward in time. We assume the observer of the system is in the direction of the positive x-axis. We want to measure the time when the inner planet transits. In this geometry, this happens when the y coordinate of the planet changes sign. Whenever we detect a change in sign between two steps, we try to find the transit time, which must lie somewhere within the last step, by bisection. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "N=174\n",
    "transittimes = np.zeros(N)\n",
    "p = sim.particles\n",
    "i = 0\n",
    "while i<N:\n",
    "    y_old = p[1].y - p[0].y  # (Thanks to David Martin for pointing out a bug in this line!)\n",
    "    t_old = sim.t\n",
    "    sim.integrate(sim.t+0.5) # check for transits every 0.5 time units. Note that 0.5 is shorter than one orbit\n",
    "    t_new = sim.t\n",
    "    if y_old*(p[1].y-p[0].y)<0. and p[1].x-p[0].x>0.:   # sign changed (y_old*y<0), planet in front of star (x>0)\n",
    "        while t_new-t_old>1e-7:   # bisect until prec of 1e-5 reached\n",
    "            if y_old*(p[1].y-p[0].y)<0.:\n",
    "                t_new = sim.t\n",
    "            else:\n",
    "                t_old = sim.t\n",
    "            sim.integrate( (t_new+t_old)/2.)\n",
    "        transittimes[i] = sim.t\n",
    "        i += 1\n",
    "        sim.integrate(sim.t+0.05)       # integrate 0.05 to be past the transit "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next, we do a linear least square fit to remove the linear trend from the transit times, thus leaving us with the transit time variations."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "A = np.vstack([np.ones(N), range(N)]).T\n",
    "c, m = np.linalg.lstsq(A, transittimes, rcond=-1)[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Finally, let us plot the TTVs."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAmcAAAFHCAYAAADk9uu6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XuYXHWd5/H3N3RiWpKORJuLIIlX4g1Iaysz6tIJCSK6\nyjL7GNsZZ0d7HRnEcXFmBGddibMzu8RnxgxeWALG6ywBL8yg+/BMsDXtjDNi2lwIasJFSXM1aQUy\ngWkgge/+UadCdXdVd13O5XfO+byep56uy6lTv19V9Tnf+l2+P3N3RERERCQMc7IugIiIiIg8Q8GZ\niIiISEAUnImIiIgERMGZiIiISEAUnImIiIgERMGZiIiISEAyD87MbKOZ7TOzXTNs8xkzu9PMdprZ\n6WmWT0RERCRNmQdnwJeANzd60MzeArzY3V8KfAC4Kq2CiYiIiKQt8+DM3X8IPDzDJu8Avhpt+2Ng\nkZkdl0bZRERERNKWeXDWhBOBe2tu3x/dJyIiIlI4eQjOREREREqjK+sCNOF+4AU1t0+K7pvGzLRQ\nqIiI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ifwTHdf4yebvcjdf+rul1Np\nbTtlyiYHo/02LWoFeygauzYH+E9Nlr9WV80Yt3cDP3T3R4AHzey8qOxmZqe2UjYRyTcFZyKSB0e6\nId19O7A7unwZ+GG97ab402jywE4qgdjNUx7/PnCamW2bOiFgprIAl0b7+iFw7wzl8AbXHwHeFE10\neAPwl9H97wIuiMr7U+CtDfYrIgWkVBoiIiIiAVHLmYiIiEhAFJyJiIiIBETBmYiIiEhAFJyJiIiI\nBETBmYiIiEhAFJyJiIiIBETBmYiIiEhAFJyJiIiIBOT/A/Z52ZaClOeBAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 720x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "fig = plt.figure(figsize=(10,5))\n",
    "ax = plt.subplot(111)\n",
    "ax.set_xlim([0,N])\n",
    "ax.set_xlabel(\"Transit number\")\n",
    "ax.set_ylabel(\"TTV [hours]\")\n",
    "plt.scatter(range(N), (transittimes-m*np.array(range(N))-c)*(24.*365./2./np.pi));"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.1+"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
